Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining armor test failures #5130

Merged
merged 4 commits into from
Feb 5, 2024

Conversation

Sleet01
Copy link
Collaborator

@Sleet01 Sleet01 commented Feb 5, 2024

This should allow the remaining failing unit tests to pass.

The issue is that the ArmorType types are not guaranteed to be initialized, because ArmorType.initializeTypes() is only called from EquipmentType.initializeTypes(), and that is only called in a few specific paths that rely on actually starting up the game itself.

I've added a check in ArmorType.of() that should avoid some infinite recursions as well.

These fixes will allow tests to pass but are pretty fragile. It would be better to ensure that ArmorTypes are always initialized no matter what, but I'm not sure where would be best so I will leave that to others.

@@ -251,6 +255,29 @@ public int getBAR() {
return bar;
}

private static ArmorType createUnknownArmor() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to have an "Unknown" armor type, which is still used in some tests / files. This should cover that option.

@neoancient neoancient merged commit 93071c0 into MegaMek:master Feb 5, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants